import React, { useEffect, useRef } from 'react'
// hooks实现防抖
function uselodash(fun, time) {
    let jsq = useRef()
    useEffect(() => {
        if (jsq.current) {
            clearTimeout(jsq.current)
        }
    }, [])
    return (...val) => {
        if (jsq.current) {
            clearTimeout(jsq.current)
        }
        jsq.current = setTimeout(() => {
            return fun(...val)
        }, time)
    }
}

export default uselodash
